import React from 'react';
import {Checkbox} from 'antd';
import {WeaSearchGroup, WeaFormItem} from 'ecCom';
import {WeaLocaleProvider} from 'ecCom';
const getLabel = WeaLocaleProvider.getLabel;
import EType from './base/EType';
import ETitle from './base/ETitle';
import EShowNum from './base/EShowNum';
import ELinkMode from './base/ELinkMode';

// 计划报告元素
export default class Content_plan extends React.Component {
    state = {
        eClassify: this.props.eClassify,
        ePlanStartDate: this.props.ePlanStartDate,
        ePlanEndDate: this.props.ePlanEndDate,
        ePlanDays: this.props.ePlanDays,
        eWeekly: this.props.eWeekly,
        eMonthly: this.props.eMonthly,
    };

    render() {
        const {eClassify, ePlanStartDate, ePlanEndDate, ePlanDays, eWeekly, eMonthly} = this.state;

        let EClassify = (
            <WeaFormItem ecId={`${this && this.props && this.props.ecId || ''}_WeaFormItem@rdlqkm`} label={getLabel(455, '分类')} labelCol={{span: 6}} wrapperCol={{span: 16}}>
                <Checkbox ecId={`${this && this.props && this.props.ecId || ''}_Checkbox@hlh23k`} size="default" checked={eClassify} onChange={e => this.setState({eClassify: e.target.checked})}/>
            </WeaFormItem>
        );

        let EPlanStartDate = (
            <WeaFormItem ecId={`${this && this.props && this.props.ecId || ''}_WeaFormItem@e1fh9g`} label={getLabel(22168, '计划开始日期')} labelCol={{span: 6}} wrapperCol={{span: 16}}>
                <Checkbox ecId={`${this && this.props && this.props.ecId || ''}_Checkbox@9zipzv`} size="default" checked={ePlanStartDate} onChange={e => this.setState({ePlanStartDate: e.target.checked})}/>
            </WeaFormItem>
        );

        let EPlanEndDate = (
            <WeaFormItem ecId={`${this && this.props && this.props.ecId || ''}_WeaFormItem@3yc510`} label={getLabel(22170, '计划结束日期')} labelCol={{span: 6}} wrapperCol={{span: 16}}>
                <Checkbox ecId={`${this && this.props && this.props.ecId || ''}_Checkbox@4e0cof`} size="default" checked={ePlanEndDate} onChange={e => this.setState({ePlanEndDate: e.target.checked})}/>
            </WeaFormItem>
        );

        let EPlanDays = (
            <WeaFormItem ecId={`${this && this.props && this.props.ecId || ''}_WeaFormItem@gpjt60`} label={getLabel(33625, '计划天数')} labelCol={{span: 6}} wrapperCol={{span: 16}}>
                <Checkbox ecId={`${this && this.props && this.props.ecId || ''}_Checkbox@47t2k4`} size="default" checked={ePlanDays} onChange={e => this.setState({ePlanDays: e.target.checked})}/>
            </WeaFormItem>
        );

        let EWeekly = (
            <WeaFormItem ecId={`${this && this.props && this.props.ecId || ''}_WeaFormItem@f1ldux`} label={getLabel(20619, '周报')} labelCol={{span: 6}} wrapperCol={{span: 16}}>
                <Checkbox ecId={`${this && this.props && this.props.ecId || ''}_Checkbox@d1a3z5`} size="default" checked={eWeekly} onChange={e => this.setState({eWeekly: e.target.checked})}/>
            </WeaFormItem>
        );

        let EMonthly = (
            <WeaFormItem ecId={`${this && this.props && this.props.ecId || ''}_WeaFormItem@ih2025`} label={getLabel(20617, '月报')} labelCol={{span: 6}} wrapperCol={{span: 16}}>
                <Checkbox ecId={`${this && this.props && this.props.ecId || ''}_Checkbox@s8239o`} size="default" checked={eMonthly} onChange={e => this.setState({eMonthly: e.target.checked})}/>
            </WeaFormItem>
        );

        return (
            <div>
                <WeaSearchGroup ecId={`${this && this.props && this.props.ecId || ''}_WeaSearchGroup@735xak`} title={getLabel(81711, '基本信息')} needTigger={true} showGroup={true}>
                    <EType ecId={`${this && this.props && this.props.ecId || ''}_EType@nwiz7i`} ref="eType" value={this.props.eBaseName}/>
                    {this.props.eShareLevel == '2' ? <ETitle ecId={`${this && this.props && this.props.ecId || ''}_ETitle@pwgb57`} ref="eTitle" eid={this.props.eid} value={this.props.eTitle} {...this.props}/> : ''}
                    <EShowNum ecId={`${this && this.props && this.props.ecId || ''}_EShowNum@fkb31l`} ref="eShowNum" value={this.props.eShowNum}/>
                    <ELinkMode ecId={`${this && this.props && this.props.ecId || ''}_ELinkMode@lhrvo6`} ref="eLinkMode" options={this.props.eLinkMode.options} value={this.props.eLinkMode.selected}/>
                    {EClassify}
                    {EPlanStartDate}
                    {EPlanEndDate}
                    {EPlanDays}
                    {EWeekly}
                    {EMonthly}
                </WeaSearchGroup>
            </div>
        );
    }

    getSaveValues() {
        return {
            eContentTitle: this.refs['eTitle'] ? this.refs['eTitle'].getSaveValues() : this.props.eTitle,
            eContentShowNum: this.refs['eShowNum'].getSaveValues(),
            eContentLinkMode: this.refs['eLinkMode'].getSaveValues(),
            eContentClassify: this.state.eClassify,
            eContentPlanStartDate: this.state.ePlanStartDate,
            eContentPlanEndDate: this.state.ePlanEndDate,
            eContentPlanDays: this.state.ePlanDays,
            eContentWeekly: this.state.eWeekly,
            eContentMonthly: this.state.eMonthly
        };
    }
}